/* ==============================================================================
 * 创 建 者：lyt
 * 创建日期：2017-07-14	
 * 功能描述：

 * 修 改 人:
 * 修改时间:
 * 修改描述：
 * ==============================================================================*/
//提现
var WithdrawSubmitUrl = baseUrl+'FinanceF/SubmitWithdraw';
//获取提现配置
var GetWithdrawSetUrl =  baseUrl+'FinanceF/SubmitWithdraw';
//会员信息获取
var getMemberViewUrl = baseUrl + 'MemberF/MemberView';

var vu;
$(function(){
	initVue();
});

function initVue(){
	vu = new Vue({
		el : '#content',
		data : {
			member : '',
			SetCoins : [],//转账币种
			ShowCoins : [],//显示币种
			chooseCoinIndex : 0,//选择币种
			
			selectedCoin : {//选择币种
				CoinOid : '',
				RemittanceMax : '',//最大值
				RemittanceMin : '',//最小值
				Radix : '',//基数
				Rate : 0,//汇率
				Ratio : '',//手续费比例
			},
			Count : '',
		},
		mounted: function() {
			this.GetWithdrawSet();
			this.getMemberView();
		},
		methods : {
			GetWithdrawSet : GetWithdrawSet,
			WithdrawSubmit : WithdrawSubmit,
			getMemberView : getMemberView,
			chooseCoin : chooseCoin,
		}
	})
}

function chooseCoin(){
	vu.selectedCoin = vu.SetCoins[vu.chooseCoinIndex];
}

function WithdrawSubmit(){
	if(!vu.selectedCoin.CoinOid){
		mui.toast("请选择币种");
		return;
	}
	if(!vu.Count){
		mui.toast("请输入提现金额");
		return;
	}
	var btnArray = ['取消', '确定'];
	mui.prompt('', '', '请输入安全密码：', btnArray, function(e) {
		if(!e.value){
			mui.toast('请输入安全密码！');
			return;
		}
        if (e.index == 1) {
            common.post(WithdrawSubmitUrl,{CoinOID : vu.selectedCoin.CoinOid,Count : vu.Count, SecondPwd : e.value},'json',function(r){
				if(r.ErrorCode==0){
					mui.toast(r.ErrorMsg);
//					vu.Count = "";
//					getMemberView();
					setTimeout(function(){
						location.href = 'withDrawRecord.html';
					},1000)
				}else{
					mui.toast(r.ErrorMsg);
				}
			})
        } 
    },'div')
	document.querySelector('.mui-popup-input input').type='password';
}

function GetWithdrawSet(){
	common.get(GetWithdrawSetUrl,{},'json',function(r){
		if(r.ErrorCode==0){
			vu.SetCoins = r.Data.SetCoins;
			vu.ShowCoins = r.Data.ShowCoins;
			if(vu.SetCoins.length){
				vu.selectedCoin = vu.SetCoins[0];
			}
		}else{
			mui.toast(r.ErrorMsg);
		}
	})
}

function getMemberView(){
	common.get(getMemberViewUrl,{},'json',function(r){
		if(r.ErrorCode==0){
			vu.member = r.Data.member;
		}else{
			mui.toast(r.ErrorMsg);
		}
	})
}

